package me.zhengjie.poemQuestions.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import io.swagger.annotations.ApiModelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.sql.Timestamp;

/**
 * 用户答题记录实体
 */
@Data
@TableName("user_answer_records")
public class UserAnswerRecord implements Serializable {

    @TableId(value = "record_id", type = IdType.AUTO)
    @ApiModelProperty(value = "记录唯一标识")
    private Integer recordId;

    @ApiModelProperty(value = "用户名称")
    private String userName;

    @ApiModelProperty(value = "关联用户表的用户ID")
    private Integer userId;

    @ApiModelProperty(value = "关联题目ID")
    private Integer questionId;

    @ApiModelProperty(value = "用户作答内容（选项字母/填空文本）")
    private String userAnswer;

    @ApiModelProperty(value = "是否正确（true正确/false错误）")
    private Boolean isCorrect;

    @ApiModelProperty(value = "本题获得积分（根据难度计算）")
    private Integer earnedPoints;

    @ApiModelProperty(value = "答题时间")
    private Timestamp answeredAt;

    public void copy(UserAnswerRecord source) {
        BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
